﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Chat_Model
{
    /// <summary>
    /// 返回消息
    /// </summary>
    public class MessageModel<T>
    {
        /// <summary>
        /// 代码
        /// </summary>
        public virtual int Code { get; set; }

        /// <summary>
        /// 消息
        /// </summary>
        public virtual string Message { get; set; }

        /// <summary>
        /// 返回数据
        /// </summary>
        public T Data { get; set; }

        /// <summary>
        /// 成功
        /// </summary>
        /// <param name="msg"></param>
        /// <param name="data"></param>
        /// <returns></returns>
        public static MessageModel<T> Successed(string msg = "",T data=default)
        {
            return new MessageModel<T>()
            {
                Code = 200,
                Message = msg,
                Data = data
            };
        }
        /// <summary>
        /// 成功
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public static MessageModel<T> Successed(T data)
        {
            return Successed(default, data);
        }

        /// <summary>
        /// 失败
        /// </summary>
        /// <param name="msg"></param>
        /// <param name="data"></param>
        /// <returns></returns>
        public static MessageModel<T> Failed(string msg = "",T data=default)
        {
            return new MessageModel<T>()
            {
                Code = 305,
                Message = msg,
                Data = data
            };
        }

        /// <summary>
        /// 失败
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public static MessageModel<T> Failed(T data)
        {
            return Failed(default, data);
        }
    }
}